<div class="header_menu">
    <div class="container">
        <div class="header-nav clearfix">
            <?php echo $this->partial('shop/layout/headerMenu'); ?>
        </div>
    </div>
</div>
</div>
<div class="container breadcrumbs">
    <a href="<?php echo $this->url('shop'); ?>"><?php echo $this->translate('首页'); ?></a>
    <span class="sep">/</span><span><?php echo $this->translate('地址管理'); ?></span>
</div>
<div class="container">
    <div class="uc-full-box">
        <div class="row">
            <div class="span4">
                <?php echo $this->partial('shop/partial/home/leftMenu'); ?>
            </div>
            <div class="span16">
                <div class="xm-line-box uc-box uc-order-detail-box">
                    <div class="box-hd">
                        <h3 class="title">
                            <?php echo $this->translate('地址管理'); ?>
                        </h3>
                        <div class="more">
                            <a href="javascript:;" onclick="userAddressModal(0);" class="btn btn-primary btn-small"><?php echo $this->translate('添加收货地址'); ?></a>
                        </div>
                    </div>
                    <div class="box-bd">
                        <table class="table table-bordered table-hover" style="margin-top: 15px;">
                            <thead>
                            <tr>
                                <th width="12%"><?php echo $this->translate('收货人'); ?></th>
                                <th width="40%"><?php echo $this->translate('收货地址'); ?></th>
                                <th width="8%"><?php echo $this->translate('邮政编码'); ?></th>
                                <th width="14%"><?php echo $this->translate('电话号码'); ?></th>
                                <th width="12%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            </thead>
                            <?php $phoneAreaCodeCount = count($this->phoneAreaCode); if ($this->userAddressList) { foreach ($this->userAddressList as $addressValue) {  ?>
                                <tr>
                                    <td><?php echo $this->escapeHtml($addressValue->getTrueName()); if($addressValue->getAddrDefault() == 1) echo '&nbsp;&nbsp;(<strong>' . $this->translate('默认') . '</strong>)'; ?></td>
                                    <td><?php echo $this->escapeHtml($addressValue->getRegionValue() . $addressValue->getAddressInfo()); ?></td>
                                    <td><?php echo $this->escapeHtml($addressValue->getPostCode()); ?></td>
                                    <td><?php echo ($phoneAreaCodeCount > 1 ? '+'.$this->phoneAreaCode[$addressValue->getAreaCode()]['areaPhoneCode'] : '') . ' ' . $this->escapeHtml($addressValue->getPhone()); ?></td>
                                    <td>
                                        <a href="javascript:;" onClick="userAddressModal(<?php echo $addressValue->getAddressId(); ?>);"><?php echo $this->translate('修改'); ?></a>
                                        &nbsp;&nbsp;
                                        <a href="javascript:;" onClick="runConfirm('<?php echo $this->translate('您确认要删除该收货地址吗?'); ?>', '<?php echo $this->url('home-user-addr', ['action' => 'deleteUserAddress', 'id' => $addressValue->getAddressId()]); ?>', 'false');"><?php echo $this->translate('删除'); ?></a></td>
                                </tr>
                            <?php } } ?>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function userAddressModal(addressId) {
        layer.open({
            type: 2,
            title: addressId > 0 ? '<?php echo $this->translate('修改地址'); ?>' : '<?php echo $this->translate('添加新地址'); ?>',
            skin: 'address-form-modal',
            scrollbar: false,
            area: ['60%', '80%'],
            content:'<?php echo $this->url('home-user-addr', ['action' => 'userAddress']); ?>?addressId='+addressId,
            end: function(index) {
                layer.load(2, {shade: [0.05, '#000'] });
                window.location.reload();
            }
        });
    }
</script>